<? Phpr_View::beginBlock("head") ?>
	<? if (!isset($fatalError)): ?>
		<? $this->renderPartial('product_types_js_setup') ?>
	<? endif ?>
	<script type="text/javascript" src="modules/shop/resources/javascript/product.js?<?= module_build('shop') ?>"></script>
	<script type="text/javascript" src="modules/shop/resources/javascript/save_item.js"></script>
	<link rel="stylesheet" href="modules/shop/resources/css/shop.css?<?= module_build('shop') ?>" type="text/css"/>
<? Phpr_View::endBlock() ?>

<? Phpr_View::beginBlock("view") ?>
	<ul class="breadcrumbs">
		<li><a href="<?= $this->getRefererUrl() ?>"><?= h($this->getRefererName()) ?></a></li>
		<li><?= $this->app_page_title ?></li>
	</ul>

	<? if (!isset($fatalError)): ?>
		<? if ($form_model->updated_at): ?>
			<div class="scoreboardReport">
				<ul>
					<li>
						<h3>Product</h3>
						<p><?= h(Phpr_Html::strTrimMiddle($form_model->name, 30)) ?></p>
						<p class="description">
							type: <?= h($form_model->product_type->name) ?>
						</p>
					</li>
					<li class="last">
						<h3>Last update by</h3>
						<p><?= h($form_model->updated_user_name) ?></p>
						<p class="description">
							at: <?= $form_model->displayField('updated_at') ?>
						</p>
					</li>
				</ul>
				<div class="clear"></div>
			</div>
		<? endif ?>
		
	<? endif ?>
	
	<? if (!isset($fatalError)): ?>
		<? if (!($lock = Db_RecordLock::lock_exists($form_model))): ?>
			<div class="form850">
				<?= Phpr_Form::openTag(array('id'=>'form_element')) ?>
					<? $this->formRender() ?>

					<?= backend_ajax_button('<u>S</u>ave', 'edit_onSave', array(), "prepareFunction: function(){phprTriggerSave();}, extraFields: {redirect: 0}, loadIndicator: {show: false}, onSuccess: function(){}, onBeforePost: LightLoadingIndicator.show.pass('Saving...'), onComplete: LightLoadingIndicator.hide, update: 'multi'") ?>
					<?= backend_ajax_button('Save and Close', 'edit_onSave', array(), "prepareFunction: function(){phprTriggerSave();}, extraFields: {edit_close: 1}") ?>
					<?= backend_ajax_button('Cancel', 'edit_onCancel') ?>

					<?= backend_ajax_button('Delete', 'edit_onDelete', array('class'=>"right"), "confirm: 'Do you really want to delete this product?'") ?>
					<div class="clear"></div>
					<input type="hidden" name="referer" value="<?= Phpr::$request->getReferer(url('/shop/products')) ?>"/>
				</form>
				<? $this->formAddLockCode() ?>
			</div>
		<? else: ?>
			<? $this->renderPartial(PATH_APP.'/modules/backend/controllers/partials/_record_locked.htm', array(
				'record_name'=>'product',
				'lock'=>$lock
			)) ?>
		<? endif ?>
	<? else: ?>
		<?= flash() ?>
		<p><a href="<?= url('/shop/products') ?>">Return to the product list</a></p>
	<? endif ?>
<? Phpr_View::endBlock() ?>